home *** CD-ROM | disk | FTP | other *** search
/ Night Owl - The Best of BBS / Night Owl The Best of BBS (NOP-BBS) (Night Owl Publisher) (1994).iso / 014a / ezbbs215.lha / Source / news2eazy.c < prev    next >
C/C++ Source or Header  |  1994-02-06  |  3KB  |  126 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <time.h>
  5. #include <proto/dos.h>
  6. #include <proto/exec.h>
  7.  
  8.  
  9.  
  10. #define VERSION "1.7"
  11. static char *version = "\0$VER: news2eazy "VERSION" ("__AMIGADATE__")";
  12.  
  13.  
  14.  
  15. void space2under(char *s)
  16. {
  17.   while (s && *s) {
  18.     if (*s==' ')
  19.       *s = '_';
  20.     s++;
  21.   }
  22. }
  23.  
  24.  
  25.  
  26. void kill_quotes(char *s)
  27. {
  28.   while (s && *s) {
  29.     if (*s=='\"')
  30.       *s = '\'';
  31.     s++;
  32.   }
  33. }
  34.  
  35.  
  36.  
  37. int main(int argc, char *argv[])
  38. {
  39.   if (argc==3) {
  40.     char tmp[80];
  41.     FILE *fp;
  42.  
  43.     sprintf(tmp,"%s%ld","MB_TMP:News2Eazy.tmp",(long)FindTask(NULL));
  44.  
  45.     if (fp=fopen(tmp,"w")) {
  46.       register int c = 0;
  47.       char username[256];
  48.       char uucpadr[256];
  49.       char *board1 = argv[1];
  50.       char *board2 = argv[2];
  51.       char subject[256];
  52.       char exec[256];
  53.       char str[1024];
  54.       BOOL ende = FALSE;
  55.  
  56.       strcpy(username,"unknown");
  57.       strcpy(subject,"none");
  58.       strcpy(uucpadr,"");
  59.  
  60.       while (!ende && fgets(str,1023,stdin)) {
  61.         if (strlen(str)==0 || strcmp(str,"\n")==0)
  62.           ende = TRUE;
  63.         else if ((strnicmp(str,"From: ",6)==0 && strlen(uucpadr)==0) || strnicmp(str,"Reply-To: ",10)==0) {
  64.           char *p;
  65.           char *str2;
  66.           str2 = strstr(str,": ")+2;
  67.  
  68.           strcpy(uucpadr,str2);
  69.           kill_quotes(uucpadr);
  70.           if (strchr(uucpadr,'\n'))
  71.             *strchr(uucpadr,'\n') = 0;
  72.  
  73. #if 0
  74.           strcpy(username,str2);
  75.           p = username;
  76.           while (*p && *p!='@') {
  77.             p++;
  78.           }
  79.           if (*p=='@')
  80.             *p = 0;
  81. #endif
  82.           if (p=strchr(str2,'@')) {
  83.             int pos;
  84.             for (pos=0,p--; p>=str2 && *p!=' ' && *p!='\t' && *p!='<'; p--)
  85.               username[pos++] = *p;
  86.             username[pos] = 0;
  87.             strrev(username);
  88.           }
  89.  
  90.           if (strchr(username,'\n'))
  91.             *strchr(username,'\n') = 0;
  92.           username[15] = 0;
  93.           kill_quotes(username);
  94.         }
  95.         else if (strnicmp(str,"Subject: ",9)==0) {
  96.           strcpy(subject,str+9);
  97.           kill_quotes(subject);
  98.           if (strchr(subject,'\n'))
  99.             *strchr(subject,'\n') = 0;
  100.           subject[40] = 0;
  101.         }
  102.       }
  103.  
  104.       while ((c=fgetc(stdin))!=EOF) {
  105.         if (c=='\\')
  106.           fputc('\\',fp);
  107.         fputc(c,fp);
  108.       }
  109.       fprintf(fp,"\n");
  110.  
  111.       fclose(fp);
  112.  
  113.       sprintf(exec,"MB:C/ImportMessage \"%s\" \"%s\" \"%s\" \"%s\" \"%s\" \"%s\"",board1,board2,username,uucpadr,subject,tmp);
  114.       System(exec,NULL);
  115.       DeleteFile(tmp);
  116.     }
  117.   }
  118.   else {
  119.     fprintf(stderr,"\033[1;33mEazyBBS\033[0m ⌐ 1988-1994 Andreas M. Kirchwitz\n"
  120.                    "Usage: news2eazy \033[3m<board1> <board2> \033[0m <text\n");
  121.   }
  122.  
  123.   exit(0);
  124. }
  125.  
  126.